package com.sxbang.bms.util;

import java.util.ArrayList;
import java.util.List;

public class BeanUtils<S, T> extends org.springframework.beans.BeanUtils {

    public static <S, T> List<T> copyProperties(List<S> source, Class<T> tCls) {
        List<T> target = new ArrayList<T>();
        T vo;
        for (S item : source) {
            if (item == null) continue;
            try {
                vo = tCls.newInstance();
            } catch (Exception e) {
                vo = null;
            }
            org.springframework.beans.BeanUtils.copyProperties(item, vo);
            target.add(vo);
        }
        return target;
    }

    public static <S, T> T copyProperties(S source, Class<T> tCls) {
        T target = null;
        try {
            target = tCls.newInstance();
        } catch (Exception e) {
            target = null;
        }
        org.springframework.beans.BeanUtils.copyProperties(source, target);
        return target;
    }

}
